Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Collections.​ObjectModel.​Collection<​T>

Assembly: System.Runtime

Inheritance: object → Collection

Implemented Interfaces

Provides the base class for a generic collection.

Properties

public int
Count
Gets the number of elements actually contained in the <see cref="T:System.Collections.ObjectModel.Collection`1" /> .
public T
Item
protected Generic.​IList<​T>
Items
Gets a <see cref="T:System.Collections.Generic.IList`1" /> wrapper around the <see cref="T:System.Collections.ObjectModel.Collection`1" /> .

Methods

public void
Add​(T item)
Adds an object to the end of the <see cref="T:System.Collections.ObjectModel.Collection`1" /> .
item The object to be added to the end of the <see cref="T:System.Collections.ObjectModel.Collection`1" /> . The value can be <see langword="null" /> for reference types.
public void
Clear​()
Removes all elements from the <see cref="T:System.Collections.ObjectModel.Collection`1" /> .
protected void
ClearItems​()
Removes all elements from the <see cref="T:System.Collections.ObjectModel.Collection`1" /> .
public bool
Contains​(T item)
Determines whether an element is in the <see cref="T:System.Collections.ObjectModel.Collection`1" /> .
Returns <see langword="true" /> if <paramref name="item" /> is found in the <see cref="T:System.Collections.ObjectModel.Collection`1" /> ; otherwise, <see langword="false" /> .
item The object to locate in the <see cref="T:System.Collections.ObjectModel.Collection`1" /> . The value can be <see langword="null" /> for reference types.
public void
CopyTo​(T[] array, int index)
Copies the entire <see cref="T:System.Collections.ObjectModel.Collection`1" /> to a compatible one-dimensional <see cref="T:System.Array" /> , starting at the specified index of the target array.
array The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied from <see cref="T:System.Collections.ObjectModel.Collection`1" /> . The <see cref="T:System.Array" /> must have zero-based indexing.
index The zero-based index in <paramref name="array" /> at which copying begins.
public Generic.​IEnumerator<​T>
GetEnumerator​()
Returns an enumerator that iterates through the <see cref="T:System.Collections.ObjectModel.Collection`1" /> .
Returns An <see cref="T:System.Collections.Generic.IEnumerator`1" /> for the <see cref="T:System.Collections.ObjectModel.Collection`1" /> .
public int
IndexOf​(T item)
Searches for the specified object and returns the zero-based index of the first occurrence within the entire <see cref="T:System.Collections.ObjectModel.Collection`1" /> .
Returns The zero-based index of the first occurrence of <paramref name="item" /> within the entire <see cref="T:System.Collections.ObjectModel.Collection`1" /> , if found; otherwise, -1.
item The object to locate in the <see cref="T:System.Collections.ObjectModel.Collection`1" /> . The value can be <see langword="null" /> for reference types.
public void
Insert​(int index, T item)
Inserts an element into the <see cref="T:System.Collections.ObjectModel.Collection`1" /> at the specified index.
index The zero-based index at which <paramref name="item" /> should be inserted.
item The object to insert. The value can be <see langword="null" /> for reference types.
protected void
InsertItem​(int index, T item)
Inserts an element into the <see cref="T:System.Collections.ObjectModel.Collection`1" /> at the specified index.
index The zero-based index at which <paramref name="item" /> should be inserted.
item The object to insert. The value can be <see langword="null" /> for reference types.
public bool
Remove​(T item)
Removes the first occurrence of a specific object from the <see cref="T:System.Collections.ObjectModel.Collection`1" /> .
Returns <see langword="true" /> if <paramref name="item" /> is successfully removed; otherwise, <see langword="false" /> . This method also returns <see langword="false" /> if <paramref name="item" /> was not found in the original <see cref="T:System.Collections.ObjectModel.Collection`1" /> .
item The object to remove from the <see cref="T:System.Collections.ObjectModel.Collection`1" /> . The value can be <see langword="null" /> for reference types.
public void
RemoveAt​(int index)
Removes the element at the specified index of the <see cref="T:System.Collections.ObjectModel.Collection`1" /> .
index The zero-based index of the element to remove.
protected void
RemoveItem​(int index)
Removes the element at the specified index of the <see cref="T:System.Collections.ObjectModel.Collection`1" /> .
index The zero-based index of the element to remove.
protected void
SetItem​(int index, T item)
Replaces the element at the specified index.
index The zero-based index of the element to replace.
item The new value for the element at the specified index. The value can be <see langword="null" /> for reference types.
public bool
Equals​(object obj)
Inherited from object
Determines whether the specified object is equal to the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
obj The object to compare with the current object.
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public int
GetHashCode​()
Inherited from object
Serves as the default hash function.
Returns A hash code for the current object.
public Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .
public string
ToString​()
Inherited from object
Returns a string that represents the current object.
Returns A string that represents the current object.